#include "intro.h"
#include "map.h"

#include <iostream>
using namespace std;

//introscreen++++++++++++++++++++++++++++++++++++
// the intro screen. It handls the buttons and
// display of the initial screen;
//-----------------------------------------------
//static vars------
introScreens::introScr* introScreens::introScr::screen = NULL;
//constructors-----
introScreens::introScr* introScreens::introScr::gsIntroScr(){
    if(screen == NULL){
        builder->get_widget_derived(iscrDesig, screen);
    }
    return screen;
}
introScreens::introScr::introScr(BaseObjectType* obj, const Glib::RefPtr<Gtk::Builder>& bld) : VBox(obj){
    Gtk::Button* ngb = NULL;
    Gtk::Button* lgb = NULL;
    builder->get_widget("NGButton", ngb);
    builder->get_widget("LGButton", lgb);
    ngb->signal_clicked().connect(sigc::mem_fun(*this, &introScreens::introScr::ngButtonHandler));
    lgb->signal_clicked().connect(sigc::mem_fun(*this, &introScreens::introScr::lgButtonHandler));
}
introScreens::introScr::~introScr(){
}
//handlers---------
void introScreens::introScr::ngButtonHandler(){
}
void introScreens::introScr::lgButtonHandler(){
}
//===============================================
//newgamescr+++++++++++++++++++++++++++++++++++++
// loads up the file chooser to load a map from
// file and start a new game
//-----------------------------------------------
//static vars------
introScreens::newGameScr* introScreens::newGameScr::screen = NULL;
//constructors-----
introScreens::newGameScr* introScreens::newGameScr::gsNewGameScr(){
    if(screen == NULL){
        builder->get_widget_derived(ngscrDesig, screen);
    }
    return screen;
}
introScreens::newGameScr::newGameScr(BaseObjectType* obj, const Glib::RefPtr<Gtk::Builder>& window) : VBox(obj){
    nmu = NULL;
    Gtk::Button* ngb = NULL;
    Gtk::Button* bkb = NULL;
    builder->get_widget_derived("ngFileChooser", nmu);
    builder->get_widget("ngNGButton", ngb);
    builder->get_widget("ngBackButton", bkb);
    ngb->signal_clicked().connect(sigc::mem_fun(*this, &introScreens::newGameScr::ngButtonHandler));
    bkb->signal_clicked().connect(sigc::mem_fun(*this, &introScreens::newGameScr::bkButtonHandler));
    nmu->loadDirectory(controll::getScnFolder(), ".uni");
    nmu->enterSignal()->connect(sigc::mem_fun(*this, &introScreens::newGameScr::esig_handler));
    nmu->set_visible(true);

}
introScreens::newGameScr::~newGameScr(){
}
//handlers---------
void introScreens::newGameScr::esig_handler(string str){\
}
void introScreens::newGameScr::ngButtonHandler(){
}
void introScreens::newGameScr::bkButtonHandler(){
}
//===============================================
//loadgamescr++++++++++++++++++++++++++++++++++++
// sets up the file chooser to load up a save game
// file
//-----------------------------------------------
//static vars-----------
introScreens::loadGameScr* introScreens::loadGameScr::screen = NULL;
//constructors----------
introScreens::loadGameScr* introScreens::loadGameScr::gsLoadGameScr(){
    if(screen == NULL){
       builder->get_widget_derived(lgscrDesig, screen) ;
    }
    return screen;
}
introScreens::loadGameScr::loadGameScr(BaseObjectType* obj, const Glib::RefPtr<Gtk::Builder>& window) : Gtk::VBox(obj){
    nmu = NULL;
    Gtk::Button* ngb = NULL;
    Gtk::Button* bkb = NULL;
    builder->get_widget_derived("lgFileChooser", nmu);
    builder->get_widget("lgLGButton", ngb);
    builder->get_widget("lgBackButton", bkb);
    ngb->signal_clicked().connect(sigc::mem_fun(*this, &introScreens::loadGameScr::lgButtonHandler));
    nmu->enterSignal()->connect(sigc::mem_fun(*this, &introScreens::loadGameScr::esig_handler));
    bkb->signal_clicked().connect(sigc::mem_fun(*this, &introScreens::loadGameScr::bkButtonHandler));
    nmu->loadDirectory(controll::getSaveFolder(), ".sav");
    nmu->set_visible(true);
}
introScreens::loadGameScr::~loadGameScr(){
}
//handlers--------------
bool introScreens::loadGameScr::on_key_press_event(GdkEventKey* key){
    nmu->keypress(key);
}
void introScreens::loadGameScr::esig_handler(string str){
    cout << str << endl;
}
void introScreens::loadGameScr::lgButtonHandler(){
    esig_handler(nmu->gChoice());
}
void introScreens::loadGameScr::bkButtonHandler(){
}
//===============================================

